﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLogic;

public partial class Admin_ConstituentInformation : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string name = "No constituent was selected.";

            if(Request.QueryString["ID"] != null)
            {
                string constituentID = Request.QueryString["ID"].ToString();
            
                if(!string.IsNullOrWhiteSpace(constituentID))
                {
                    Constituent constituent = new Constituent(new Guid(constituentID));                    
                    name = constituent.Name;                    
                    
                    if(string.IsNullOrWhiteSpace(name))
                    {
                        name = "Name isn't currently available.";
                    }                                       
                    
                    Common.Utility.BindGridView<Address>(grvAddresses, constituent.Addresses);
                    Common.Utility.BindGridView<Phone>(grvPhones, constituent.Phones);
                    Common.Utility.BindGridView<Email>(grvEmails, constituent.EmailAddresses);
                }
            }
            
            lblName.Text = name;
        }
    }    
} 